import Banner from "../Banner";
import { 头盔, 手枪, 防弹衣, 突击步枪, 冲锋枪, 射手步枪, 栓动步枪, 轻机枪, 霰弹枪, 卡宾枪, 投掷物, 子弹, 药品, 食物, } from "../Datas/Data";
import { Constant, ItemType } from "../Framework/Const/Constant";
import AudioManager from "../Framework/Managers/AudioManager";
import { DataManager } from "../Framework/Managers/DataManager";
import { PoolManager } from "../Framework/Managers/PoolManager";
import { UIManager } from "../Framework/Managers/UIManager";
import NodeUtil from "../Framework/Utils/NodeUtil";
import SpecialSkinItem from "./SpecialSkinItem";

const { ccclass, property } = cc._decorator;

@ccclass
export default class SpecialSkinShopPanel extends cc.Component {
    ItemContent: cc.Node = null;

    items: cc.Node[] = [];

    protected onLoad(): void {
        this.ItemContent = NodeUtil.GetNode("ItemContent", this.node);
    }

    Show() {
        Banner.Instance.ShowCustomAd();
        AudioManager.PlayAudio(Constant.Audio.ButtonClick);
        this.RefreshItems();
    }

    RefreshItems() {
        this.items.forEach(e => PoolManager.PutNode(e));
        let items = [];
        items.push(DataManager.JunXuItems.find(e => e.Name == "AX50-龙影"));
        items.push(DataManager.JunXuItems.find(e => e.Name == "FAL-赛博涂鸦"));
        items.push(DataManager.JunXuItems.find(e => e.Name == "MPX-白金之星"));
        items.push(DataManager.JunXuItems.find(e => e.Name == "G18C-矩形几何"));

        for (let i = 0; i < items.length; i++) {
            const data = items[i];
            PoolManager.GetNode("Prefabs/UI/SpecialSkinItem", this.ItemContent).then(e => {
                let item = e.getComponent(SpecialSkinItem);
                item.Init(data)
                this.items.push(e);
            })
        }
    }

    OnReturnButtonClick() {
        AudioManager.PlayAudio(Constant.Audio.ButtonClick);
        UIManager.Instance.HidePanel(Constant.Panel.SpecialSkinShopPanel);
    }
}